//订单查询
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            shopVisitManageInfo: {
                visits: [],
                total: 0,
                records: 1,
                conditions: {
                    visitUserName: '',
                    visitIp: '',
                    visitId: '',
                    shopId: ''
                }
            }
        },
        _initMethod: function () {
            $that._listShopVisits(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('shopVisitManage', 'goBack', function (_param) {
                $that.shopVisitManageInfo.orderDetail = false;
            });
            vc.on('shopVisitManage', 'list', function () {
                $that._listShopVisits(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listShopVisits(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listShopVisits: function (_page, _rows) {
                $that.shopVisitManageInfo.conditions.page = _page;
                $that.shopVisitManageInfo.conditions.row = _rows;
                $that.shopVisitManageInfo.conditions.shopId = vc.getCurrentCommunity().shopId;
                let param = {
                    params: $that.shopVisitManageInfo.conditions
                };
                param.params.visitId = param.params.visitId.trim();
                param.params.visitUserName = param.params.visitUserName.trim();
                param.params.visitIp = param.params.visitIp.trim();
                //发送get请求
                vc.http.apiGet('/shopVisit.queryShopVisit',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.shopVisitManageInfo.total = _json.total;
                        $that.shopVisitManageInfo.records = _json.records;
                        $that.shopVisitManageInfo.visits = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.shopVisitManageInfo.records,
                            dataCount: $that.shopVisitManageInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _queryOrdersMethod: function () {
                $that._listShopVisits(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _resetOrdersMethod: function () {
                $that.shopVisitManageInfo.conditions.visitId = "";
                $that.shopVisitManageInfo.conditions.visitUserName = "";
                $that.shopVisitManageInfo.conditions.visitIp = "";
                $that._listShopVisits(DEFAULT_PAGE, DEFAULT_ROWS);
            }
        }
    });
})(window.vc);
